//
//  NRWCarPushNoticeCell.m
//  New_Runway
//
//  Created by NewLife on 2018/2/24.
//  Copyright © 2018年 NelsonJ. All rights reserved.
//

#import "NRWCarPushNoticeCell.h"
#import "NRWCarPushMsgModel.h"

@implementation NRWCarPushNoticeCell
{
    UIImageView *_iconView;
    UILabel *_titleLabel;
    UILabel *_timeLabel;
    UILabel *_detailLabel;
}

- (void)setModel:(NRWCarPushMsgModel *)model {
    
    _model = model;
    
    _iconView.image = [UIImage imageNamed:@"notice_p"];
    _titleLabel.text = model.title;
    _detailLabel.text = model.alert;
    _timeLabel.text = model.timeStr;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.backgroundColor = self.contentView.backgroundColor = [UIColor whiteColor];
        self.opaque = self.contentView.opaque = YES;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        [self setupUI];
        [self layoutUI];
    }
    return self;
}

- (void)setupUI {
    
    _iconView = [[UIImageView alloc] init];
    _iconView.backgroundColor = [UIColor whiteColor];
    _iconView.opaque = YES;
    
    _titleLabel = [[UILabel alloc] init];
    _titleLabel.font = kPingFangRegular15();
    _titleLabel.textColor = kColorDeepBlack();
    _titleLabel.backgroundColor = [UIColor whiteColor];
    _titleLabel.opaque = YES;
    
    _timeLabel = [[UILabel alloc] init];
    _timeLabel.font = kPingFangRegular13();
    _timeLabel.textColor = Gray98Color();
    _timeLabel.backgroundColor = [UIColor whiteColor];
    _timeLabel.opaque = YES;
    
    _detailLabel = [[UILabel alloc] init];
    _detailLabel.font = kPingFangRegular13();
    _detailLabel.textColor = Gray98Color();
    _detailLabel.backgroundColor = [UIColor whiteColor];
    _detailLabel.opaque = YES;
    
    [self.contentView addSubview:_iconView];
    [self.contentView addSubview:_titleLabel];
    [self.contentView addSubview:_timeLabel];
    [self.contentView addSubview:_detailLabel];
}

- (void)layoutUI {
    
    [_iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.mas_top).offset(15);
        make.left.equalTo(self.contentView.mas_left).offset(15);
        make.width.height.equalTo(@50);
    }];
    
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_iconView.mas_top);
        make.left.equalTo(_iconView.mas_right).offset(15);
    }];
    
    [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView.mas_right).offset(-15);
        make.centerY.equalTo(_titleLabel.mas_centerY);
    }];
    
    [_detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(_iconView.mas_bottom);
        make.left.equalTo(_iconView.mas_right).offset(15);
        make.right.equalTo(self.contentView.mas_right).offset(-15);
    }];
    
}

@end
